import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {HttpServicesProvider} from "../../providers/http-services/http-services";
import {ValidateProvider} from "../../providers/validate/validate";
import {ConfigProvider} from "../../providers/config/config";

@IonicPage({
    segment: 'member/bond',
    defaultHistory: ['MemberPage']
})
@Component({
    selector: 'page-person-bond',
    templateUrl: 'person-bond.html',
})
export class PersonBondPage {
    token: any;
    frozen_money: any;
    frozen_detail: any;

    constructor(
        public navCtrl: NavController,
        public navParams: NavParams,
        public httpService: HttpServicesProvider,
        public validate: ValidateProvider,
        public config: ConfigProvider
    ) {

    }

    //判断用户是否登录
    ionViewCanEnter(){
        return this.validate.checkLogin();
    }

    ionViewWillEnter() {
        this.token = this.config.getToken();
        this.getData();
    }

    getData() {
        //获取保证金金额
        this.httpService.requestPostData('/echarge/residue_recharge_frozen', {token: this.token}, response => {
            let data = response['data'];
            this.frozen_money = data['frozen_money'];
        });
        //获取保证金明细
        this.httpService.requestPostData('/echarge/recharge_frozen_log', {token: this.token}, response => {
            let data = response['data'];
            this.frozen_detail = data['list'];
        });
    }
}
